import {defineStore} from "pinia";

// import { ThemeEnum } from "@/enums/ThemeEnums";

interface SseState {
    message_time: string;
    message_datetime: string;
    user_count: number;
    pipeline_count: number;
    webhook_count: number,
    pipeline_list: [];
    webhook_list: []
}


export const useSseStore = defineStore("sse-store", {
    state: (): SseState => ({
        message_time: "",
        message_datetime: "",
        user_count: 0,
        pipeline_count: 0,
        webhook_count: 0,
        pipeline_list: [],
        webhook_list: []
    }),
    getters: {

    },
    actions: {
        // changeTime(data: string): void {
        //     this.message_time = data
        // },
        // changeDatetime(data: string): void {
        //     this.message_datetime = data
        // },
        // changeUserCount(data: number): void {
        //     this.user_count = data
        // },
        // changePipelineCount(data: number): void {
        //     this.pipeline_count = data
        // },
        // changeWebhookCount(data: number): void {
        //     this.webhook_count = data
        // },
        // changePipelineList(data: []): void {
        //     this.pipeline_list = data
        // },
        // changeWebhookList(data: []): void {
        //     this.webhook_list = data
        // },
        changeWebhookStatus(data: any){
            this.webhook_list.forEach(item => {
                if (item.id == data.id) {
                    item.status = data.status
                }
            })
        },
        changePipelineStatus(data: any){
            this.pipeline_list.forEach(item => {
                if (item.id == data.id) {
                    item.status = data.status
                }
            })
        },
    },
});
